/**
 * @name html帮助类
 */
; var htmlHelper = (function ($, window, document, undefined) {
	/**
	 * html转义
	 * @param str 需要转义的字符串
	 */
	var Encode = function(str){
		var div = document.createElement("div");
		div.appendChild(document.createTextNode(str));
		return div.innerHTML;
		
		//传统写法
		//var s = ""; 
		//if (str.length == 0) return ""; 
		//s = str.replace(/&/g, "&amp;"); 
		//s = s.replace(/</g, "&lt;"); 
		//s = s.replace(/>/g, "&gt;"); 
		//s = s.replace(/ /g, "&nbsp;"); 
		//s = s.replace(/\'/g, "&#39;"); 
		//s = s.replace(/\"/g, "&quot;"); 
		//s = s.replace(/\n/g, "<br/>"); 
		//return s; 
	};
	
	/**
	 * html反向转义
	 * @param str 需要反向转义的字符串
	 */
	var Decode = function(str){
		var s = ""; 
		if (str.length == 0) return ""; 
		s = str.replace(/&amp;/g, "&"); 
		s = s.replace(/&lt;/g, "<"); 
		s = s.replace(/&gt;/g, ">"); 
		s = s.replace(/&nbsp;/g, " "); 
		s = s.replace(/&#39;/g, "\'"); 
		s = s.replace(/&quot;/g, "\""); 
		s = s.replace(/<br\/>/g, "\n"); 
		return s; 
	};
	
	return {
		Encode: Encode,
		Decode: Decode,
		
	};
})(jQuery, window, document);